//Edited by CJH
//This flie is used to input movebase server
#ifndef __ACTION_CLIENT_H_
#define __ACTION_CLIENT_H_


#include<iostream>
#include<vector>
#include<list>
#include <map>


#include <ros/ros.h>
#include <string.h>
#include <move_base_msgs/MoveBaseAction.h>
#include <actionlib/client/simple_action_client.h>
#include <nav_msgs/Path.h>

#include <algorithm>
#include <eigen3/Eigen/Core>
#include <eigen3/Eigen/Geometry>



using namespace std;

//定义导航的模式
const int sinpoint_navi_mode=1;
const int multipoint_navi_mode=2;
const int multipoint_cruise_mode=3;

namespace IPPNS{


    /*路径点设置服务端*/
    class pahtserver
{
    public:
        //构造一个Pose变量来存储路径点
        geometry_msgs::PoseStamped WayPoint;
    
    protected:
        list<geometry_msgs::PoseStamped> Waypoints_list;  //导航路径点的双向队列

    /*用于路径点更改的私类接口*/
    private:
    /*用于路径点更改的公共类接口*/
    public:
        void printflist();
        int current_point;
        /*查看、删除、查看、更改数值*/
        void waypoint_delete();
        geometry_msgs::PoseStamped waypoint_check();
        void waypoint_data_change(geometry_msgs::PoseStamped *newpoint);
        /*增添、插入*/
        void waypoint_add(geometry_msgs::PoseStamped *newpoint);
        void waypoint_insert(geometry_msgs::PoseStamped *newpoint,int pos);
        /*清除*/
        void waypoint_clear();


    public:
        pahtserver();
        ~pahtserver();
    };
      pahtserver::pahtserver()
    {
    }
    pahtserver::~pahtserver()
    {
    }


    /*设置导航服务端，继承路径服务端*/
    class naviserver: public pahtserver 
    {
    /*用于导航的私类接口*/
    private:
        ros::NodeHandle node;
        ros::Publisher pub;
        move_base_msgs::MoveBaseGoal goal;
        geometry_msgs::PoseStamped posestamped;
        /*move_base导航服务器声明*/
        typedef actionlib::SimpleActionClient<move_base_msgs::MoveBaseAction> MoveBaseClient;
        
        /*用于单点导航接口*/
        void auto_single_move();
        /*用于多点导航接口*/
        void auto_multi_move();
        /*用于多点巡航接口*/
        void auto_cruise_move();

        
    

    public:
        //设置紧急停止API接口
        bool emergency();
        //设重启API接口
        int  respawn_flag=0;
        bool respawn();
        //初始化自动导航
        void auto_navigation_init(int mode);
    private:
        /* data */
        vector<vector<double>> point2D;
	    vector<vector<double>> CubicSplineParameter;//a, b, c, d.
	    vector<double> h;
	    vector<double> m;

    public:
        naviserver(/* args */);
        ~naviserver();
    };
    
    naviserver::naviserver(/* args */)
    {
    }
    
    naviserver::~naviserver()
    {
    }



    /*设置下位机通讯服务端*/
    class touchserver
    {
    private:
        /* data */
    public:
        touchserver(/* args */);
        ~touchserver();
    };
    
    touchserver::touchserver(/* args */)
    {
    }
    
    touchserver::~touchserver()
    {
    }
    
 

}

#endif
